<?php
/*
$JA#COPYRIGHT$
*/

class mod_jafeatured_employerHelper
{ 
    function get_list_profiles( $model, $employer_list,  $limit, $is_hiring, $max_employer ){
    	
		global $jbconfig, $mainframe;				
		if(!$employer_list) return ;
		$limitstart = 0;
		
		$where_more = ' and a.approved=1 ';
        $join = '';
		$where_more .= " and a.id in ($employer_list)";
		$where_more .= " and rs.block=0";
		if($is_hiring) $where_more .= ' and emplo.hiring='. (int)$is_hiring;
		$all_items = $model->getItems($where_more, $max_employer, $limitstart, 'emplo.ordering', $join);  		
		if (($limit<count($all_items))&&$limit>0)
		{
			$temp = array_rand($all_items,$limit);
			$tmp_items = array();
			if (is_array($temp))	
			{
				for ($i=0;$i<count($temp);$i++)
					$tmp_items[] = $all_items[$temp[$i]];
			}
			else 
				$tmp_items[] = $all_items[$temp];
			$all_items = $tmp_items;
		}
		
		return $all_items;
	}
	
	function getFile($name, $modPath, $tmplPath) {
		if (file_exists(JPATH_SITE.DS.$tmplPath.$name)) {
			return $tmplPath.$name;
		}
		return $modPath.$name;
	}    
}
?>